package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.sys.entity.SysCollegeEntity;
import io.renren.modules.sys.entity.SysLaboratoryEntity;
import io.renren.modules.sys.service.SysLaboratoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 实验室管理
 *
 * @author liao mengqing
 */
@RestController
@RequestMapping("sys/laboratory")
public class SysLaboratoryController {
    @Autowired
    private SysLaboratoryService sysLaboratoryService;

    /**
     * 分页查询实验室信息列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:laboratory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysLaboratoryService.queryPage(params);
        return R.ok().put("page", page);
    }


     /**
     * 信息
     */
    @RequestMapping("/info/{laboratoryId}")
    @RequiresPermissions("sys:laboratory:info")
    public R info(@PathVariable("laboratoryId") Long laboratoryId){
        SysLaboratoryEntity sysLaboratory = sysLaboratoryService.getById(laboratoryId);

        return R.ok().put("sysLaboratory", sysLaboratory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:laboratory:save")
    public R save(@RequestBody SysLaboratoryEntity sysLaboratory){
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:laboratory:update")
    public R update(@RequestBody SysLaboratoryEntity sysLaboratory){

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:laboratory:delete")
    public R delete(@RequestBody Long[] laboratoryIds){
		sysLaboratoryService.removeByIds(Arrays.asList(laboratoryIds));
        return R.ok();
    }

    /**
     * tree实验室
     * @return
     */
    @GetMapping("/select")
    @RequiresPermissions("sys:laboratory:select")
    public R select(){
        //查询列表数据
        List<SysLaboratoryEntity> laboratoryList = sysLaboratoryService.queryListLaboratory();
        return R.ok().put("laboratoryList", laboratoryList);
    }
}
